import { createRouter, createWebHashHistory } from 'vue-router'

import Layout from '@/views/layout'
import Home from '@/views/home'
import GoodDetail from '@/views/goods'
import Cart from '@/views/cart'
import Order from '@/views/Member/order/index.vue'
import Pay from '@/views/Member/pay'
// 登录页
import Login from '@/views/login'

const PayResult = () => import('@/views/Member/pay/result')

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: Home
      },
      {
        path: '/detail/:id',
        component: GoodDetail
      },
      {
        path: '/cart',
        component: Cart
      },
      {
        path: '/order',
        component: Order
      },
      {
        path: '/pay',
        component: Pay
      },
      {
        path: '/pay/callback',
        component: PayResult
      }
    ]
  },
  {
    path: '/login',
    component: Login
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  // 每次跳转，另一个页面都是顶部
  scrollBehavior () {
    return {
      left: 0, top: 0
    }
  }
})

export default router
